<?php

class comment_upModel extends Model
{
    public function getUpIds($uid, $type, $commentIds) {
        $commentIdArr = explode(',', $commentIds);
        if(!$commentIds) {
            return [];
        }
        $sql = "select comment_id from wf_comment_up where uid={$uid} and type={$type} and comment_id in ({$commentIds})";
        $list = $this->query($sql)->fetchAll();
        $upCommentIdArr = [];
        if($list) {
            foreach ($list as $row) {
                $upCommentIdArr[$row['comment_id']] = true;
            }
        }
        $resultData = [];
        foreach ($commentIdArr as $id) {
            $resultData[] = [
                'commentId' => intval($id),
                'isUp' => isset($upCommentIdArr[$id])?1:0
            ];
        }
        return $resultData;
    }
}